#include "xmlWidget.h"
using namespace xmlWidgetLib;

#include <iostream>
#include <string>
using namespace std;

#include "xmlWidgetEventHandler.h"
#include "logManager.h"
/*
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************
*/

void xmlWidget::parseXmlMainMenu(void) throw( string * )
{
	logger << __FUNCTION__ << " Start" << endl;


	m_Widget = gtk_vbox_new( FALSE,0 );
	GtkWidget *parent = m_ParentWidget->getGtkWidget();
	gtk_container_add( GTK_CONTAINER( parent ), m_Widget);

	m_EmbleWidget = gtk_menu_bar_new();
	gtk_box_pack_start( GTK_BOX(m_Widget),m_EmbleWidget,FALSE,TRUE,0);


	logger << __FUNCTION__ << " Success" << endl;
}

void xmlWidget::parseXmlMenu(void) throw( string * )
{
	logger << __FUNCTION__ << " Start" << endl;

	const char *title = m_XmlRoot->Attribute("title");
	if( title )
	{
		logger << __FUNCTION__ << "menu tile <" << title << ">" << endl;
		m_Widget = gtk_menu_item_new_with_label(title);
	}
	if( NULL == m_Widget )
	{
		throw new string("Error: can not new menu");
	}

	m_EmbleWidget = gtk_menu_new();

	gtk_menu_item_set_submenu( GTK_MENU_ITEM(m_Widget), m_EmbleWidget );

	GtkWidget *parent = m_ParentWidget->getGtkEmbleWidget();
	if( NULL == parent )
	{
		throw new string("Error: can not new menu no emble menu");
	}
	gtk_menu_bar_append( GTK_MENU_BAR( parent ), m_Widget);

	logger << __FUNCTION__ << " Success" << endl;
}

void xmlWidget::parseXmlMenuItem(void) throw( string * )
{
	logger << __FUNCTION__ << " Start" << endl;

	const char *title = m_XmlRoot->Attribute("title");
	if( title )
	{
		logger << __FUNCTION__ << "menu tile <" << title << ">" << endl;
		m_Widget = gtk_menu_item_new_with_label(title);
	}
	if( NULL == m_Widget )
	{
		throw new string("Error: can not new menu");
	}
	gtk_signal_connect_object( GTK_OBJECT(m_Widget), "activate",
                GTK_SIGNAL_FUNC(MenuItem_CallBack), (gpointer)this );

	GtkWidget *parent = m_ParentWidget->getGtkEmbleWidget();
	if( NULL == parent )
	{
		throw new string("Error: can not new menu item no emble menu");
	}
	gtk_menu_append( GTK_MENU ( parent ), m_Widget);

	logger << __FUNCTION__ << " Success" << endl;
}


void xmlWidget::parseXmlPopMenu(void) throw( string * )
{
	logger << __FUNCTION__ << " Start" << endl;
	logger << __FUNCTION__ << " Success" << endl;
}

